]> dgit.raspbian.org Git - ostree.git/commit
static-delta: guard bspatch against integer truncation on 32-bit
authorJoseph Marrero Corchado <jmarrero@redhat.com>
Wed, 15 Jul 2026 17:07:03 +0000 (13:07 -0400)
committerJoseph Marrero Corchado <jmarrero@redhat.com>
Wed, 15 Jul 2026 17:07:03 +0000 (13:07 -0400)
commit88f35c5afb6f86c18e8f17d28259ac00336a5051
tree7c033d56a0c23b23803bf3b9a407bb943bd2df2a
parentae08c555201ec382ed8ae4fc118e7a714cbb32bb
static-delta: guard bspatch against integer truncation on 32-bit

On 32-bit systems (sizeof(gsize)==4), the attacker-controlled
content_size (a guint64) is silently truncated when passed to
g_malloc0(), which takes gsize.  Meanwhile bspatch() receives the
full 64-bit value as int64_t newsize and writes according to it,
producing a heap buffer overflow.

Add an explicit check that content_size fits in both gsize and int64_t
before the allocation.  Use separate typed locals (alloc_size, newsize)
to make the truncation-free intent clear and pass newsize to bspatch().

Addresses: RHEL-189207
CWE-680, CWE-122, CWE-190
src/libostree/ostree-repo-static-delta-processing.c